package com.czk.config;

import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/11/2 22:13
 */
@Configuration
@MapperScan("com.czk.mapper")
public class MpConfig {
    /**
     * 注入乐观锁插件
     *
     * @return
     */
    @Bean
    public OptimisticLockerInterceptor optimisticLockerInterceptor() {
        return new OptimisticLockerInterceptor();
    }

    /**
     * 分页查询插件
     *
     * @return
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        Properties p=new  Properties();
        p.setProperty("logical","true");
        paginationInterceptor.setProperties(p);
        return paginationInterceptor;
    }
}
